package com.moli.iov.down.command.codec.utils;

/**
 * <p>
 *
 * </p>
 *
 * @author: zql
 * @Date: 2018/11/30 11:31
 */
public class Protocol {

    /**
     * 协议头 2字节
     */
    private byte[] startTag = {0x23,0x23};

    /**
     * 命令标识 1字节
     */
    private byte commandTag;

    /**
     * 应答标志 1字节
     */
    private byte responseTag;

    /**
     * 唯一识别码 VIN 17字节
     */
    private String vin;

    /**
     * 加密码方式 1字节
     * 0x01：数据不加密；0x02：数据经过 RSA 算法加密；0x03：数据经过
     * AES128 位算法加密；“0xFE”表示异常，“0xFF”表示无效，其他预
     * 留
     */
    private byte[] encryptTag = {0x01};

    /**
     * 数据单元长度 2字节
     */
    private int dataLen;

    /**
     * 数据单元
     */
    private byte[] data;

    /**
     * 校验码 1字节
     */
    private byte checkCode;

    public Protocol setStartTag(byte[] startTag) {
        this.startTag = startTag;
        return this;
    }

    public Protocol setCommandTag(byte commandTag) {
        this.commandTag = commandTag;
        return this;
    }

    public Protocol setResponseTag(byte responseTag) {
        this.responseTag = responseTag;
        return this;
    }

    public Protocol setVin(String vin) {
        this.vin = vin;
        return this;
    }

    public Protocol setEncryptTag(byte[] encryptTag) {
        this.encryptTag = encryptTag;
        return this;
    }

    public Protocol setDataLen(int dataLen) {
        this.dataLen = dataLen;
        return this;
    }

    public Protocol setData(byte[] data) {
        this.data = data;
        return this;
    }

    public Protocol setCheckCode(byte checkCode) {
        this.checkCode = checkCode;
        return this;
    }

    public byte[] getStartTag() {
        return startTag;
    }

    public byte getCommandTag() {
        return commandTag;
    }

    public byte getResponseTag() {
        return responseTag;
    }

    public String getVin() {
        return vin;
    }

    public byte[] getEncryptTag() {
        return encryptTag;
    }

    public int getDataLen() {
        return dataLen;
    }

    public byte[] getData() {
        return data;
    }

    public byte getCheckCode() {
        return checkCode;
    }
}
